<?php
/**
 * Created by PhpStorm.
 * User: Lenovo
 * Date: 2018/9/30
 * Time: 10:17
 */
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use app\admin\model\SzxinxiangModel;
use app\admin\model\UserModel;

class MayorMailboxController extends AdminBaseController
{
    public function  daiban()
    {
            $szxinxiangModel = new SzxinxiangModel();
            $where = ['deal' => 1];
           $data =   $szxinxiangModel->getMsgList1($where);
           $this->assign('deal',1);
           $this-> assign('liebiao',$data);
            return   $this->fetch('xinxiang');
    }

    public function  hdeal(){
        $szxinxiangModel = new SzxinxiangModel();
        $where = ['deal' => 2];
        $this->assign('deal',2);
        $data =   $szxinxiangModel->getMsgList1($where);
        $this-> assign('liebiao',$data);
        return   $this->fetch('xinxiang2');
    }

    //市长信箱已反馈
    public function gback(){
        $szxinxiangModel = new SzxinxiangModel();
        $where = ['deal' => 3];
        $this->assign('deal',3);
        $data =   $szxinxiangModel->getMsgList1($where);
        $this-> assign('liebiao',$data);
        return   $this->fetch('xinxiang2');
    }

    //市长信箱已处理
    public function overdeal(){
        $szxinxiangModel = new SzxinxiangModel();
        $where = ['deal' => 4];
        $this->assign('deal',4);
        $data =   $szxinxiangModel->getMsgList1($where);
        $this-> assign('liebiao',$data);
        return   $this->fetch('xinxiang2');
    }

    public function del()
    {
        $data = input('');
        $szxinxiangModel = new SzxinxiangModel();
     $res =   $szxinxiangModel->del($data['id']);
        if ($res)
        {
            return $this->success('删除成功');
        }else
        {
            return $this->error('删除失败');
        }
    }
    public function msg()
    {
        $szxinxiangModel = new SzxinxiangModel();
        $data = input('');

        $user = new UserModel();
        $userList = $user->userList();
        $this->assign('users',$userList);
        $szxinxiangModel = new SzxinxiangModel();
     $msg =    $szxinxiangModel->msg(['id' =>$data['id'] ]);
     $this->assign('msg',$msg);

     if ($data['deal'] == 1) //未递交
     {
         $username = $user->adminName();
         $this->assign('username',$username);
         return $this->fetch('chacont');
     }
     if ($data['deal']== 2 )
     {
         $username = $user->selectName($data['id']);
         $this->assign('username',$username);
         return $this->fetch('chacont2');
     }
        if ($data['deal']== 3 )
        {
            $username = $user->selectName($data['id']);
            $this->assign('username',$username);
            return $this->fetch('chacont3');
        }
        if ($data['deal']== 4 )
        {
            $username = $user->selectName($data['id']);
            $this->assign('username',$username);
            return $this->fetch('chacont4');
        }

    }


    //分发部门
        public  function  give(){
        $data = input("");
            $szxinxiangModel = new SzxinxiangModel();
        $res =     $szxinxiangModel->dealTo2($data['id'],$data['dealunit']);
        if ($res)
        {
            return $this->success('递交成功','MayorMailbox/daiban');
        }else
        {
            return $this->error('递交失败');
        }

        }

        //更换内容
    public function changeContent()
    {
        $data = input("");
        $szxinxiangModel = new SzxinxiangModel();
        $res =    $szxinxiangModel->changeContent($data['id'],$data['content']);
        if ($res)
        {
            return $this->success('修改成功');
        }else
        {
            return $this->error('修改失败');
        }

    }

    //修改受理单位
    public function changeUnit()
    {
        $data = input('');
        $szxinxiangModel = new SzxinxiangModel();
      $res =  $szxinxiangModel->dealUnit($data['id'],$data['dealunit']);
        if ($res)
        {
            return $this->success('修改成功');
        }else
        {
            return $this->error('修改失败');
        }
    }
    //回复信息审核状态
    public function check(){
      $data = input('');
        $szxinxiangModel = new SzxinxiangModel();
      $res =   $szxinxiangModel->deal($data['id'],4);
      $res1 =   $szxinxiangModel->overTIme($data['id']);

        if ($res && $res1)
        {
            return $this->success('审核成功','MayorMailbox/gback');
        }else
        {
            return $this->error('审核失败');
        }
    }

    //重新审核
    public function recheck(){

        $data = input('');
        $szxinxiangModel = new SzxinxiangModel();
      $res=   $szxinxiangModel->deal($data['id'],3);
        if ($res)
        {
            return $this->success('提交成功','MayorMailbox/overdeal');
        }else
        {
            return $this->error('提交失败');
        }
    }
}